import { Injectable, NestMiddleware } from '@nestjs/common';
import { LoggerService } from '@/common/logger/logger.service';
import { Request, Response } from 'express';
import { getReqMainInfo } from '@/utils/request.info';

@Injectable()
export class LogMiddleware implements NestMiddleware {
  constructor(private readonly logger: LoggerService) { }
  use(req: Request, res: Response, next: () => void) {
    // 记录日志
    this.logger.log(getReqMainInfo(req), req.url)
    next();
  }
}
